/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Customers.java
 *
 * Created on Sep 8, 2010, 6:23:43 AM
 */

package GUI;

import BusinessLogic.SalesMenFunction_BL;
import javax.swing.table.TableModel;

/**
 *
 * @author MrToan
 */
public class Customers extends javax.swing.JFrame {

    /** Creates new form Customers */
    public Customers() {
        initComponents();
        GetCusTableValues();
    }
    SalesMenFunction_BL function_BL=new SalesMenFunction_BL();
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        tbCustomers = new javax.swing.JTable();
        bntSelect = new javax.swing.JButton();

        tbCustomers.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tbCustomers.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tbCustomersMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(tbCustomers);

        bntSelect.setText("Select");
        bntSelect.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bntSelectActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 623, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addGap(266, 266, 266)
                .addComponent(bntSelect)
                .addContainerGap(296, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 184, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(bntSelect)
                .addContainerGap(20, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void tbCustomersMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbCustomersMouseClicked

        Count=tbCustomers.getSelectedRow();
    }//GEN-LAST:event_tbCustomersMouseClicked

    private void bntSelectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntSelectActionPerformed
        // TODO add your handling code here:

        SalesMen.txtCustomer.setText((String)tbCustomers.getValueAt(Count, 0));
        this.dispose();
    }//GEN-LAST:event_bntSelectActionPerformed
    

    public void GetCusTableValues()
    {
        TableModel tb=function_BL.UserTable();
        tbCustomers.setModel(tb);
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton bntSelect;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable tbCustomers;
    // End of variables declaration//GEN-END:variables

    private int Count;
}
